package com.wyzy.mybatis.mapper;

import com.wyzy.mybatis.model.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserInfoMapper {
    @Select("select * from user_info")
    List<UserInfo> quaryAllUser();

    // 查
    @Select("select * from user_info where id= #{id}")
    UserInfo queryById(@Param("id") Integer id);

    // 增
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into user_info (username, `password`, age, gender, phone)" +
            "values (#{username},#{password},#{age},#{gender},#{phone})")
    Integer insert(UserInfo userInfo);

    // 删
    @Delete("delete from user_info where id = #{id}")
    Integer delete(Integer id);

    // 改
    @Update("update user_info set username=#{username} where id=#{id}")
    Integer update(UserInfo userInfo);
}
